{template /common/header}
<div class="ruzhubox">
  <form name="form1" action="{U('user/bank')}" method="post" class="secuform">
    <div class="box">
      <div class="accleft tit">用户名：</div>
      {$userInfoList[username]}
      <div class="clear"></div>
    </div>
    <?php
	if($userInfoList["true_name"]==""){
  ?>
    <div class="box">
      <div class="accleft tit">真实姓名：</div>
      <input type="text" class="accleft textbox phonebox"  datatype="zh2-4"  name="true_name" id="true_name"  nullmsg="请输入真实姓名" errormsg="真实姓名格式错误！">
      <div class="clear"></div>
    </div>
    <div class="box">
      <div class="accleft tit">身份证号：</div>
      <input type="text" class="accleft textbox phonebox" datatype="idcard"  name="idcard" id="idcard" nullmsg="请输入身份证号码" errormsg="请输入身份证号码！">
      <div class="clear"></div>
    </div>
    <?php
	}else{
  ?>
    <div class="box">
      <div class="accleft tit">真实姓名：</div>
      {$userInfoList[true_name]}
      <div class="clear"></div>
    </div>
    <div class="box">
      <div class="accleft tit">身份证号：</div>
      {$userInfoList[idcard]}
      <div class="clear"></div>
    </div>
    <?php
	}
  ?>
    <div class="box">
      <div class="accleft tit">当前手机号：</div>
      <input type="text" class="accleft textbox numbox noborder" value="<?php echo $this->userinfo['mobile_phone'];?>">
      <a href="javascript:;" class="code send_code">免费获取验证码</a>
      <div class="clear"></div>
    </div>
    <div class="box">
      <div class="accleft tit">验证码：</div>
      <input type="text" class="accleft textbox phonebox" name="code" datatype="n" value="" maxlength="5">
      <div class="clear"></div>
    </div>
    <div class="box">
      <div class="accleft tit">开户行信息：</div>
      <input type="text" name="bankaddress" id="bankaddress" value="{$userInfoList[bankaddress]}" datatype="*2-30"  class="accleft textbox phonebox" nullmsg="请输入开户行信息！" errormsg="请输入开户行信息！" placeholder="XX银行XX市分行XX支行"/>
      <div class="clear"></div>
    </div>
    <div class="box">
      <div class="accleft tit">银行卡号：</div>
      <input type="text" name="banknum" id="banknum" value="{$userInfoList[banknum]}" datatype="n10-22"  class="accleft textbox phonebox" nullmsg="请输入银行卡号码！" errormsg="请输入银行卡号码！"/>
      <div class="clear"></div>
    </div>
    <div class="zhucefor errmsg" id="win"> </div>
    <a href="javascript:void(0);" class="jiansuobut">添加银行卡</a>
  </form>
</div>
<script type="text/javascript">
        
$(function(){

    $(".send_code").click(function(){
        var text=$(this).text();
        var type=$(this).attr("type");
        if(text!="免费获取验证码"){
            return false;
        }
    var mobile=$("#mobile_phone").val();
    if(mobile==""){
      alert("请填写您的手机号码");
      $("#mobile_phone").blur();
      return;
    }
    $.ajax({url: "{U('User/Public/send_code')}&token={$_SESSION[send_code_time]}&mobile=<?php echo $this->userinfo['mobile_phone'];?>",timeout: 5000,cache: false,type: "get",async : false,dataType: "json",success: function (d) {
      if(d.status==1){
         downtime(120); 
      }
      alert(d.info);
    }});
    })

})


function downtime(time){

//循环调用

if(time == '0'){

$('.send_code').text('免费获取验证码');

}else{

time --;

$('.send_code').text('重新发送（'+time+'）');

setTimeout(function() {

downtime(time);

},1000);} 

}
</script> 
<script type="text/javascript">
            $(function() {
                $(".secuform").Validform({
                    tiptype:function(msg,o,cssctl){
						if(o.type==1){
							o.obj.addClass("Validform_success")
						}
						if(o.type==3){
							o.obj.removeClass("Validform_success").addClass("Validform_error")
							$(".errmsg").text(msg).show();
							return false;
						}
					},
					datatype:{//传入自定义datatype类型【方式二】;
						"zh2-4":/^[\u4E00-\u9FA5\uf900-\ufa2d]{2,4}$/,
						"idcard":function(gets,obj,curform,datatype){
							//该方法由佚名网友提供;
						
							var Wi = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 ];// 加权因子;
							var ValideCode = [ 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ];// 身份证验证位值，10代表X;
						
							if (gets.length == 15) {   
								return isValidityBrithBy15IdCard(gets);   
							}else if (gets.length == 18){   
								var a_idCard = gets.split("");// 得到身份证数组   
								if (isValidityBrithBy18IdCard(gets)&&isTrueValidateCodeBy18IdCard(a_idCard)) {   
									return true;   
								}   
								return false;
							}
							return false;
							
							function isTrueValidateCodeBy18IdCard(a_idCard) {   
								var sum = 0; // 声明加权求和变量   
								if (a_idCard[17].toLowerCase() == 'x') {   
									a_idCard[17] = 10;// 将最后位为x的验证码替换为10方便后续操作   
								}   
								for ( var i = 0; i < 17; i++) {   
									sum += Wi[i] * a_idCard[i];// 加权求和   
								}   
								valCodePosition = sum % 11;// 得到验证码所位置   
								if (a_idCard[17] == ValideCode[valCodePosition]) {   
									return true;   
								}
								return false;   
							}
							
							function isValidityBrithBy18IdCard(idCard18){   
								var year = idCard18.substring(6,10);   
								var month = idCard18.substring(10,12);   
								var day = idCard18.substring(12,14);   
								var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));   
								// 这里用getFullYear()获取年份，避免千年虫问题   
								if(temp_date.getFullYear()!=parseFloat(year) || temp_date.getMonth()!=parseFloat(month)-1 || temp_date.getDate()!=parseFloat(day)){   
									return false;   
								}
								return true;   
							}
							
							function isValidityBrithBy15IdCard(idCard15){   
								var year =  idCard15.substring(6,8);   
								var month = idCard15.substring(8,10);   
								var day = idCard15.substring(10,12);
								var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));   
								// 对于老身份证中的你年龄则不需考虑千年虫问题而使用getYear()方法   
								if(temp_date.getYear()!=parseFloat(year) || temp_date.getMonth()!=parseFloat(month)-1 || temp_date.getDate()!=parseFloat(day)){   
									return false;   
								}
								return true;
							}
						}
					},
                    ajaxPost: true,
                    callback: function(data) {
                        if (data.status == '1') {
                            alert(data.info);
                            location.href = "{U('user/bank')}";
                        }else{
                            alert(data.info);
                        }
                    }
                });
              
            });

            $(".jiansuobut").click(function(){
                $(".secuform").submit();
            })
        </script> 
{template /common/footer}